#include"UdpServer.hpp"
#include"Dictionary.hpp"

#include <memory>
using namespace LogMoudule;

int main(int argc, char *argv[])
{
    ENABLE_CONSOLE_LOG();
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " localport" << std::endl;
        Die(USAGE_ERR);
    }
    // std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);


    std::shared_ptr<Dictionary> dictionary =std::make_shared<Dictionary>();

    std::unique_ptr<UdpServer> server =std::make_unique<UdpServer>(
        [&dictionary](const std::string &word)
        {
            // std::cout << "|" << word << "|" << std::endl;
            return dictionary->Translate(word);
        }
        ,port);

    server->InitServer();
    server->Start();

    return 0;
}